//349
/**
 * Note: The returned array must be malloced, assume caller calls free().
 */
int* intersection(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize){
  int count=0;
    int arr[1001]={0};
    int *p=(int*)malloc(sizeof(int)*nums2Size);
    for(int i=0;i<nums1Size;i++)
    {
        arr[nums1[i]]=1;
    }

    for(int i=0;i<nums2Size;i++)
    {
        if(arr[nums2[i]]==1)
        {
            p[count]=nums2[i];
            count++;
            arr[nums2[i]]=0;
        }
    }
    *returnSize=count;
    return p;
}